package com.xiaoq.logs.service.impl;

import com.xiaoq.logs.entity.NginxLog;
import com.xiaoq.logs.repository.NginxLogRepository;
import com.xiaoq.logs.service.NginxLogService;
import org.apache.commons.lang3.StringUtils;
import org.mongodb.morphia.Datastore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by chenjh on 2018/2/11.
 */
@Service
public class NginxLogServiceImpl implements NginxLogService {

    private static final Logger LOGGER = LoggerFactory.getLogger(NginxLogServiceImpl.class);

    @Autowired
    private NginxLogRepository nginxLogRepository;

    @Override
    public boolean save(NginxLog nginxLog) {
        return nginxLogRepository.save(nginxLog);
    }

    @Override
    public List<NginxLog> findNginxLogList(String shopId, Long maxMillis, Long minMillis) {
        return nginxLogRepository.findNginxLogList(shopId, maxMillis, minMillis);
    }

    @Override
    public long findNginxLogCount(String shopId, Long maxMillis, Long minMillis) {
        return nginxLogRepository.findNginxLogCount(shopId, maxMillis, minMillis);
    }

    @Override
    public long findNginxLogCountUv(String shopId, Long maxMillis, Long minMillis) {
        return nginxLogRepository.findNginxLogCountUv(shopId, maxMillis, minMillis);
    }

    @Override
    public List<NginxLog> findNginxLogList(String shopId, String requestUrl, Double minRequestTime, Long beginMillis, Long endMillis) {
        return nginxLogRepository.findNginxLogList(shopId, requestUrl, minRequestTime, beginMillis, endMillis);
    }
}
